Skip to content

docs: Correct label mapping and add oco git configuration instructions#10

Merged
Rasic2 merged 2 commits intomasterfrom
dev/zhouh
Sep 13, 2025
Merged

docs: Correct label mapping and add oco git configuration instructions#10
Rasic2 merged 2 commits intomasterfrom
dev/zhouh

Conversation

@Rasic2
Copy link
Owner

@Rasic2 Rasic2 commented Sep 13, 2025

Summary by CodeRabbit

  • Documentation

    • Added guidance for an optional OpenCommit setting (OCO_OMIT_SCOPE) to omit scope in AI-generated commit messages, with a sample configuration command and placement in the OpenCommit usage docs. Documentation-only; no behavioral changes to the app.
  • Chores

    • Adjusted PR title auto-labeling mapping so only "docs" (not "doc") maps to the "documentation" label, affecting label assignment for PRs.

@coderabbitai
Copy link

coderabbitai bot commented Sep 13, 2025

Walkthrough

Added documentation for a new optional OpenCommit config key OCO_OMIT_SCOPE and updated a GitHub Actions PR-title-to-label mapping (replaced 'doc' key with 'docs' → 'documentation'). Changes are documentation and CI workflow config only; no runtime code changes.

Changes

Cohort / File(s) Summary
Documentation: OpenCommit optional config
docs/source/development/git.md
Inserted documentation entry for OCO_OMIT_SCOPE with example usage oco config set OCO_OMIT_SCOPE=true (omit scope in commit messages). Documentation-only change.
CI workflow: PR title label mapping
.github/workflows/pr-auto-label.yml
Updated PR title keyword-to-label mapping: replaced key 'doc' with 'docs' mapping to documentation. Labeling logic otherwise unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through lines of text,
I nudge a key, leave code unvexed.
"Omit the scope," I softly cry,
Labels tweaked too — a small supply.
Thump-thump, I dance — docs and CI, quick and spry. 🥕

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev/zhouh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title "docs: Correct label mapping and add oco git configuration instructions" accurately and concisely summarizes the two primary changes in the PR (fixing the PR-title label mapping and adding documentation for OCO_OMIT_SCOPE), is specific to the changeset, and contains no extraneous file lists or vague wording, so it is suitable for reviewers scanning history.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 13, 2025
@Rasic2 Rasic2 changed the title docs: add instruction for omitting scope in oco git configuration docs: Correct label mapping and add oco git configuration instructions Sep 13, 2025
@github-actions github-actions bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/pr-auto-label.yml (1)

47-55: Handle Conventional Commit scopes (e.g., "docs(ui): ...").

Current normalization doesn't strip "(scope)", so keywords won’t match. Strip optional scope before lookup.

-            for (const word of words) {
-              const normalizedWord = word.toLowerCase().replace(/^[\W_]+|[\W_]+$/g, '');
-              
-              if (keywordMap.hasOwnProperty(normalizedWord)) {
-                labelsToAdd.add(keywordMap[normalizedWord]);
+            for (const word of words) {
+              const normalizedWord = word.toLowerCase().replace(/^[\W_]+|[\W_]+$/g, '');
+              const typeOnly = normalizedWord.replace(/\(.*$/, ''); // drop optional "(scope"
+
+              if (keywordMap.hasOwnProperty(typeOnly)) {
+                labelsToAdd.add(keywordMap[typeOnly]);
                 break; // 找到第一个匹配就停止
               }
             }
🧹 Nitpick comments (3)
.github/workflows/pr-auto-label.yml (3)

33-35: Keep backward compatibility: map both "docs" and "doc".

Dropping "doc" breaks existing PR title conventions (e.g., "doc: ..."). Add an alias to avoid regressions.

               'improvement': 'enhancement',
-              'docs': 'documentation',
+              'docs': 'documentation',
+              'doc': 'documentation',
               'readme': 'documentation',

57-72: Don’t remove unrelated labels; only manage the label set this workflow owns.

removeAllLabels can wipe manually applied labels. Remove only labels this workflow controls.

-              // 首先清除所有现有标签
-              try {
-                await github.rest.issues.removeAllLabels({
-                  issue_number: context.issue.number,
-                  owner: context.repo.owner,
-                  repo: context.repo.repo
-                });
-                console.log('All existing labels removed');
-              } catch (error) {
-                console.log('Error removing labels:', error.message);
-              }
+              // 仅移除由该工作流管理的标签,避免误删其他标签
+              const managed = new Set(Object.values(keywordMap));
+              const existing = (context.payload.pull_request.labels || []).map(l => l.name);
+              const toRemove = existing.filter(name => managed.has(name));
+              for (const name of toRemove) {
+                try {
+                  await github.rest.issues.removeLabel({
+                    issue_number: context.issue.number,
+                    owner: context.repo.owner,
+                    repo: context.repo.repo,
+                    name,
+                  });
+                } catch (error) {
+                  console.log(`Error removing label ${name}:`, error.message);
+                }
+              }

3-9: Forked PRs won’t get labels with pull_request + write perms.

If you need labeling on forked PRs, consider pull_request_target (with care) so the token has write on the base repo. Keep the script minimal and avoid using fork-supplied code/inputs to mitigate risk.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12f5fb0 and d1eda2e.

📒 Files selected for processing (1)
  • .github/workflows/pr-auto-label.yml (1 hunks)

@Rasic2 Rasic2 merged commit 3172c80 into master Sep 13, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant